package com.hf.lookatme.zview.activitys;

import android.os.Bundle;

import com.hf.lookatme.R;
import com.hf.lookatme.zbean.RegionData;
import com.hf.lookatme.zpresenter.Present_Activity_PartTimeJob_SelectWorkLocation;
import com.hf.lookatme.zview.adapters.Adapter_WheelView_WorkLocation;
import com.hf.lookatme.customview.wheel.WheelView;
import com.hf.lookatme.customview.wheel.listener.OnWheelChangedListener;
import com.hf.lookatme.zview.interfaces.IView_Activity_PartTimeJob_SelectWorkLocation;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by JoeShiguang on 2015/6/7.
 */
public class Activity_PartTimeJob_SelectWorkLocation extends Activity_Base implements IView_Activity_PartTimeJob_SelectWorkLocation {

  private Present_Activity_PartTimeJob_SelectWorkLocation present;

  @InjectView(R.id.wheelView_selectLocation_province)
  WheelView wheelView_province;

  @InjectView(R.id.wheelView_selectLocation_city)
  WheelView wheelView_city;

  @InjectView(R.id.wheelView_selectLocation_area)
  WheelView wheelView_area;

  private int currentProvinceID, currentCityID, currentAreaID = 0; // 设置默认值id

  private Adapter_WheelView_WorkLocation adapter_province, adapter_city, adapter_area;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parttimejob_selectworklocation);
    ButterKnife.inject(this);
  }

  private void initControls() {

    wheelView_province.addChangingListener(new WheelChangedListener());
    wheelView_province.setVisibleItems(3);
  }


  @Override
  public void buildProvinceWheelView(List<RegionData> list_province) {

    adapter_province = new Adapter_WheelView_WorkLocation(Activity_PartTimeJob_SelectWorkLocation.this, list_province);
    present.getCityData(Activity_PartTimeJob_SelectWorkLocation.this, 0);
  }

  @Override
  public void buildCityWheelView(List<RegionData> list_city) {

    adapter_city = new Adapter_WheelView_WorkLocation(Activity_PartTimeJob_SelectWorkLocation.this, list_city);

  }

  @Override
  public void buildAreaWheelView(List<RegionData> list_area) {

  }

  class WheelChangedListener implements OnWheelChangedListener {
    @Override
    public void onChanged(WheelView wheel, int oldValue, int newValue) {
      if (wheel == wheelView_province) {

        currentProvinceID = newValue;
        present.getCityData(Activity_PartTimeJob_SelectWorkLocation.this, currentProvinceID);
      } else if (wheel == wheelView_city) {

        currentCityID = newValue;
        present.getAreaData(Activity_PartTimeJob_SelectWorkLocation.this, currentCityID);
      } else if (wheel == wheelView_area) {
        currentAreaID = newValue;
      }
    }
  }
}
